package com.yykj.tencent.im.server.service.impl;

import com.yykj.tencent.im.server.bean.request.*;
import com.yykj.tencent.im.server.bean.response.*;
import com.yykj.tencent.im.server.core.TimUtil;
import com.yykj.tencent.im.server.dto.ContactDTO;
import com.yykj.tencent.im.server.service.SnsService;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
@Slf4j
public class SnsServiceImpl implements SnsService {


    /**
     * 版本
     */
    private final String Version = "v4";

    /**
     * 关系链管理服务名
     */
    private static final String SERVICE_NAME = "sns";

    /**
     * 关系链管理相关命令字
     */
    private static final String FRIEND_ADD_COMMAND = "friend_add";
    private static final String FRIEND_IMPORT_COMMAND = "friend_import";
    private static final String FRIEND_UPDATE_COMMAND = "friend_update";
    private static final String FRIEND_DELETE_COMMAND = "friend_delete";
    private static final String FRIEND_DELETE_ALL_COMMAND = "friend_delete_all";
    private static final String FRIEND_CHECK_COMMAND = "friend_check";
    private static final String FRIEND_GET_COMMAND = "friend_get";
    private static final String FRIEND_GET_LIST_COMMAND = "friend_get_list";
    private static final String BLACK_LIST_ADD_COMMAND = "black_list_add";
    private static final String BLACK_LIST_DELETE_COMMAND = "black_list_delete";
    private static final String BLACK_LIST_GET_COMMAND = "black_list_get";
    private static final String BLACK_LIST_CHECK_COMMAND = "black_list_check";
    private static final String GROUP_ADD_COMMAND = "group_add";
    private static final String GROUP_DELETE_COMMAND = "group_delete";
    private static final String GROUP_GET_COMMAND = "group_get";

    /**
     * 请求接口
     */
    private final String api_url = "%s/%s/%s";


    /**
     * 添加好友
     */
    @SneakyThrows
    @Override
    public FriendAddResult friendAdd(FriendAddRequest friendAddRequest) {
        String api = String.format(api_url, Version, SERVICE_NAME,FRIEND_ADD_COMMAND);
        return TimUtil.post(api,friendAddRequest,FriendAddResult.class);
    }

    /**
     * 导入好友
     */
    @SneakyThrows
    @Override
    public FriendImportResult friendImport(FriendImportRequest friendImportRequest) {
        String api = String.format(api_url, Version, SERVICE_NAME,FRIEND_IMPORT_COMMAND);
        return TimUtil.post(api,friendImportRequest,FriendImportResult.class);
    }

    /**
     * 更新好友
     */
    @SneakyThrows
    @Override
    public FriendUpdateResult friendUpdate(FriendUpdateRequest friendUpdateRequest) {
        String api = String.format(api_url, Version, SERVICE_NAME,FRIEND_UPDATE_COMMAND);
        return TimUtil.post(api,friendUpdateRequest,FriendUpdateResult.class);
    }

    /**
     * 删除好友
     */
    @SneakyThrows
    @Override
    public FriendDeleteResult friendDelete(FriendDeleteRequest friendDeleteRequest) {
        String api = String.format(api_url, Version, SERVICE_NAME,FRIEND_DELETE_COMMAND);
        return TimUtil.post(api,friendDeleteRequest,FriendDeleteResult.class);
    }

    /**
     * 删除所有好友
     */
    @SneakyThrows
    @Override
    public FriendDeleteAllResult friendDeleteAll(FriendDeleteAllRequest friendDeleteAllRequest) {
        String api = String.format(api_url, Version, SERVICE_NAME,FRIEND_DELETE_ALL_COMMAND);
        return TimUtil.post(api,friendDeleteAllRequest,FriendDeleteAllResult.class);
    }


    @Override
    public FriendCheckResult friendCheck(FriendCheckRequest friendCheckRequest) {
        return null;
    }

    /**
     * 拉取好友
     */
    @SneakyThrows
    @Override
    public FriendGetResult friendGet(FriendGetRequest friendGetRequest) {
        String api = String.format(api_url, Version, SERVICE_NAME,FRIEND_GET_COMMAND);
        return TimUtil.post(api,friendGetRequest,FriendGetResult.class);
    }

    @Override
    public FriendGetListResult friendGetList(FriendGetListRequest friendGetListRequest) {
        return null;
    }

    @Override
    public BlackListAddResult blackListAdd(BlackListAddRequest blackListAddRequest) {
        return null;
    }

    @Override
    public BlackListDeleteResult blackListDelete(BlackListDeleteRequest blackListDeleteRequest) {
        return null;
    }

    @Override
    public BlackListGetResult blackListGet(BlackListGetRequest blackListGetRequest) {
        return null;
    }

    @Override
    public BlackListCheckResult blackListCheck(BlackListCheckRequest blackListCheckRequest) {
        return null;
    }

    @Override
    public GroupAddResult groupAdd(GroupAddRequest groupAddRequest) {
        return null;
    }

    @Override
    public GroupDeleteResult groupDelete(GroupDeleteRequest groupDeleteRequest) {
        return null;
    }

    @Override
    public GroupGetResult groupGet(GroupGetRequest groupGetRequest) {
        return null;
    }
}
